<%--
  Created by IntelliJ IDEA.
  User: wangjunneil@gmail.com
  Date: 13-12-17
  Time: 16:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/page/common/jsptag.jsp"%>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="<%=request.getContextPath() %>/bg/css/bg.css" type="text/css" />
    <script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript">
        function editRegionValue(obj, id) {
            if (obj.editable) return;

            var input = document.createElement("input");
            input.type = 'text';
            input.style = 'font-family: arial,helvetica,sanserif;font-size:10px;height:' + obj.offsetHeight + 'px;width:' + obj.offsetWidth + 'px';
            input.value = obj.title;
            input.onkeydown = function() {
                var event = window.event || arguments[0];
                if (event.keyCode == 13) {
                    if (input.value == obj.title) {
                        obj.removeChild(input);
                        obj.innerHTML = input.value;
                        obj.editable = false;
                        return;
                    }
                    $.ajax({type:'POST', url:'updateRegion.html', data:'value=' + input.value + "&id=" + id});
                    obj.title = input.value;
                    obj.removeChild(input);
                    obj.innerHTML = input.value;
                    obj.editable = false;
                }
            }

            obj.editable = true;
            obj.replaceChild(input, obj.firstChild);
        }
    </script>
</head>
<body>
<div id="listDiv">
    <table id="filmTable">
        <thead>
        <tr>
            <th width="30%">ID</th>
            <th width="70%">名称</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="region" items="${regionList}">
            <tr>
                <td align="center">${region.regionId}</td>
                <td title="${region.regionName}" ondblclick="editRegionValue(this,${region.regionId});">
                    ${region.regionName}
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
</html>